function _() {}

const defaultOptions = {
    errorCallback: _,
    throwOnError: false,
    delimiters: [
        { left: "$$", right: "$$", display: true },
        { left: "$", right: "$", display: false },
        { left: "\\[", right: "\\]", display: true },
        { left: "\\(", right: "\\)", display: false }
    ]
}

function render(el, binding) {
    let options = {}
    if (binding.value) {
        options = binding.value.options || {}
    }
    Object.assign(options, defaultOptions)
    window.renderMathInElement(el, options)
}

export default {
    install: function(Vue, options) {
        Vue.directive("katex", {
            bind: render,
            componentUpdated: render
        })
    }
}
